<?php

namespace App\Http\Middleware;

use App\Model\User;
use App\Model\Role;
use App\Model\Permission;
use Closure;

class HasRole
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //1.获取当前请求路由
        $route = \Route::current()->getActionName();

        //2.获取当前用户的权限组
        $user_permiss = session()->get('user_permiss');

        //判断当前请求的路由是否在权限组中
//        if(!in_array($route,$user_permiss)){
//            return redirect('/admin/noaccess');
//        }
        return $next($request);
    }
}
